#ifndef __BUOLA_GUI_X11_CX11PICTURE_H__
#define __BUOLA_GUI_X11_CX11PICTURE_H__

#include <X11/extensions/Xrender.h>

#include <buola/gui/x11/cx11window.h>
#include <buola/image/cgc.h>

namespace buola { namespace gui { namespace x11 {

class CX11Picture
{
public:
    enum EFlags
    {
        PICTURE_NONE=0,
        PICTURE_REPEAT=(1<<0),
        PICTURE_NOEXPOSURES=(1<<2),
        PICTURE_INFERIORS=(1<<3),
        PICTURE_COMPALPHA=(1<<4)
    };
    DECLARE_FRIEND_ENUM_BITOPS(EFlags)
    
    CX11Picture();
    CX11Picture(Drawable,int,EFlags);
    CX11Picture(Drawable,Visual*,EFlags);
    CX11Picture(Picture,bool);
    ~CX11Picture();

    void Create(Drawable,int,EFlags);
    void Create(Drawable,Visual*,EFlags);
    void Create(Picture,bool);
    void CreateSolid(const img::CColor &pColor);
    void CreateAlpha(unsigned int);

    void Destroy();

    void SetClip(const CFixesRegion&);
    void SetTransform(const CX11Matrix&);
    void SetFilter(const std::string&);

    void FillRect(const CRect_d&,const img::CColor&,img::ECompOp pOp=img::ECompOp::OVER);

    static void Composite(const CX11Picture &pSrc,const CX11Picture &pMask,
            const CX11Picture &pDest,const CPoint_d &pSrcPos,
            const CPoint_d &pMaskPos,const CPoint_d &pDestPos,
            const CSize_d &pSize,img::ECompOp pOp=img::ECompOp::OVER);

    Picture GetID()         {   return mPicture;    }
private:
    Picture mPicture;
    bool mOwned;

public:
    static const CX11Picture mNull;
};

/*namespace x11*/ } /*namespace gui*/ } /*namespace buola*/ }

#endif
